﻿#include "MaterialDescriptionEditWidget.h"
#include "ui_MaterialDescriptionEditWidget.h"
#include "GUIFrame/MainWindow.h"


namespace GUI {
    MaterialDescriptionEditWidget::MaterialDescriptionEditWidget(MainWindow *mw, QString name, QString desc) :
        GUIWidgetBase(mw), _ui(new Ui::MaterialDescriptionEditWidget)
    {
        _ui->setupUi(this);
        this->setAttribute(Qt::WA_DeleteOnClose, false);
        this->setWindowTitle(QString("%1,Material: %2").arg(windowTitle(), name));
        _ui->plainTextEdit->setPlainText(desc);
    }

    MaterialDescriptionEditWidget::~MaterialDescriptionEditWidget()
    {
        //析构清除界面
        delete _ui;
    }

    QString MaterialDescriptionEditWidget::getDescText() const
    {
        //获取描述文本
        return _text;
    }

    void MaterialDescriptionEditWidget::on_pb_ok_clicked()
    {
        //ok按钮点击事件
        _text = _ui->plainTextEdit->document()->toPlainText();
        //this->accept();
    }

    void MaterialDescriptionEditWidget::on_pb_cancel_clicked()
    {
        //cancel按钮点击事件
        //this->reject();
    }
}
